<?php

namespace App\Http\Validate\Kms\Poi;

use App\Http\Validate\AbstractBaseValidate;
use App\Models\Kms\Album\AlbumResourceModel;
use Illuminate\Support\MessageBag;
use Illuminate\Validation\ValidationException;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;

class PoiValidate extends AbstractBaseValidate
{
    function getRules(): array
    {
        // TODO: Implement getRules() method.
        return [
            //longitude and latitude
            "lng"  => self::stringValidateBuild(true, 20),
            "lat"  => self::stringValidateBuild(true, 20),
            "type" => ["required", "string", "in:" . implode(",", array_keys(AlbumResourceModel::POI_TYPE_A_MAP_TEXT)).",ALL"],
        ];
    }

    function getAttributes(): array
    {
        // TODO: Implement getAttributes() method.
        return [];
    }

    function registerValidateRules(): void
    {
        // TODO: Implement registerValidateRules() method.
    }

    function getMessages(): array
    {
        // TODO: Implement getMessages() method.
        return [
            "lng" => "经度",
            "lat" => "纬度"
        ];
    }

    /**
     * @param array $params
     * @return MessageBag|object
     * @throws ValidationException
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public static function listValidate(array $params)
    {
        return self::getInstance()->validate(["lat", "lng"], $params);
    }

    /**
     * @param array $params
     * @return MessageBag|object
     * @throws ValidationException
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public static function aMapListValidate(array $params)
    {
        return self::getInstance()->validate(["lat", "lng", "type"], $params);
    }
}
